package com.axonactive.yolo.webservice;

import java.io.IOException;

import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;

import com.axonactive.yolo.webservice.utils.Utils;

@Path("/notification")
public class Notification {
	
	/**
	 * @param 
	 * KEY: notificationListParam
	 * VALUE: {"userId":300,"timeStamp":"1399281563703"}
	 * @return
	 * @throws IOException
	 * @throws InterruptedException
	 */
	@POST
	@Path("/list")
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	public String getNotificationList(MultivaluedMap<String, String> param) throws IOException, InterruptedException {
		return Utils.call("get_notification_list/" + param.getFirst("notificationListParam"));
	}
	
	/**
	 * @param 
	 * KEY: readNotificationParam
	 * VALUE: {"userId":300,"type":"single/all","notificationId":110/null}
	 * @return
	 * @throws IOException
	 * @throws InterruptedException
	 */
	@POST
	@Path("/mark_read")
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	public String markReadNotification(MultivaluedMap<String, String> param) throws IOException, InterruptedException {
		return Utils.call("mark_read_notification/" + param.getFirst("readNotificationParam"));
	}
	
	/**
	 * @param 
	 * KEY: removeNotificationParam
	 * VALUE: {"userId":300,"type":"single/all","notificationId":110/null}
	 * @return
	 * @throws IOException
	 * @throws InterruptedException
	 */
	@POST
	@Path("/remove")
	@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
	@Produces(MediaType.APPLICATION_JSON)
	public String removeNotification(MultivaluedMap<String, String> param) throws IOException, InterruptedException {
		return Utils.call("remove_notification/" + param.getFirst("removeNotificationParam"));
	}
}
